]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
systemActions: Switch to updated CanShutdown() API
authorAdrian Vovk <adrianvovk@gmail.com>
Fri, 27 Feb 2026 20:58:17 +0000 (15:58 -0500)
committerMarge Bot <marge-bot@gnome.org>
Tue, 3 Mar 2026 04:57:17 +0000 (04:57 +0000)
There's corresponding changes in gnome-session that report more detail
about the availability of the action. This allows gnome-shell to
appropriately hide the action whenever it is inhibited, and would lead
to a Polkit prompt.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4040>

data/dbus-interfaces/org.gnome.SessionManager.xml
js/misc/gnomeSession.js
js/misc/systemActions.js

index c81c90f087fcc4d0a68c3e7b4edc966429a88017..74a3a2e558d1a69ef3c4187f6f0cc077ee8771ff 100644 (file)
@@ -6,7 +6,7 @@
     <method name="Shutdown"/>
     <method name="Reboot"/>
     <method name="CanShutdown">
-      <arg type="b" direction="out"/>
+      <arg type="u" direction="out"/>
     </method>
     <method name="IsInhibited">
       <arg type="u" direction="in"/>
index 21825042904081586e45fa2dbdac46b2b9e04f87..45526c74b125aa75ad8d8ea59db308edcccf3168 100644 (file)
@@ -62,3 +62,10 @@ export const InhibitFlags = {
     IDLE: 1 << 3,
     AUTOMOUNT: 1 << 4,
 };
+
+export const ActionAvailability = {
+    UNAVAILABLE: 0,
+    BLOCKED: 1,
+    CHALLENGE: 2,
+    AVAILABLE: 3,
+};
index 710d42fa547aa08163a092d697cbfd7a2992dc07..eb358e37adbfe3fabe2a83d4234c5dab04a05560 100644 (file)
@@ -82,6 +82,7 @@ const SystemActions = GObject.registerClass({
         super._init();
 
         this._canHavePowerOff = true;
+        this._powerOffNeedsAuth = false;
         this._canHaveSuspend = true;
 
         function tokenizeKeywords(keywords) {
@@ -345,10 +346,12 @@ const SystemActions = GObject.registerClass({
 
     async _updateHaveShutdown() {
         try {
-            const [canShutdown] = await this._session.CanShutdownAsync();
-            this._canHavePowerOff = canShutdown;
+            const [availability] = await this._session.CanShutdownAsync();
+            this._canHavePowerOff = availability !== GnomeSession.ActionAvailability.UNAVAILABLE;
+            this._powerOffNeedsAuth = availability === GnomeSession.ActionAvailability.CHALLENGE;
         } catch {
             this._canHavePowerOff = false;
+            this._powerOffNeedsAuth = false;
         }
         this._updatePowerOff();
     }
@@ -356,6 +359,7 @@ const SystemActions = GObject.registerClass({
     _updatePowerOff() {
         const disabled = (Main.sessionMode.isLocked &&
                         !this._screenSaverSettings.get_boolean(RESTART_ENABLED_KEY)) ||
+                       (Main.sessionMode.isLocked && this._powerOffNeedsAuth) ||
                        (Main.sessionMode.isGreeter &&
                         this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY));
         this._actions.get(POWER_OFF_ACTION_ID).available = this._canHavePowerOff && !disabled;